package cn.ad.server.domain.enumration;

import java.util.HashMap;

public enum Age {
	AGE14ANDLESS("14岁及以下",0,14,1),//	'14岁及以下',
	AGE15TO18("15-18岁",15,18,2),//	'15-18岁',
	AGE19TO24("19-24岁",19,24,4),//	'19-24岁',
	AGE25TO30("25-30岁",25,30,8),//	'25-30岁',
	AGE31TO35("31-35岁",31,35,16),//	'31-35岁',
	AGE36TO40("36-40岁",36,40,32),//	'36-40岁',
	AGE41TO45("41-45岁",41,45,64),//	'41-45岁',
	AGE46TO50("46-50岁",46,50,128),//	'46-50岁',
	AGE51TO55("51-55岁",51,55,256),//	'51-55岁',
	AGE56TO60("56-60岁",56,60,512),//	'56-60岁',
	AGE61TO64("61-64岁",61,64,1024),//	'61-64岁',
	AGE65ANDTHAN("65岁及以上",65,200,2048);//	'65岁及以上'
	
    private String name;
    private int value;
    private int lower;
    private int higher;
    
    public static HashMap<String,Age> ageMap;
    public static HashMap<Integer,Age> ageMapByVal;

    static {
    	ageMap = new HashMap<>();
        for (Age age : values()) {
        	ageMap.put(age.getName(), age);
        }
    }
    
    static {
    	ageMapByVal = new HashMap<>();
    	for (Age age : values()) {
    		ageMapByVal.put(age.value, age);
    	}
    }

    private Age(String name, int lower, int higher, int value) {
        this.name = name;
        this.lower = lower;
        this.higher=higher;
        this.value = value;
    }

    public String getName() {
        return name;
    }

	public int getValue() {
		return value;
	}
	
	 public int getHigher() {
		return higher;
	}
	 
	 public int getLower() {
		return lower;
	}

	public void setLower(int lower) {
		this.lower = lower;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setValue(int value) {
		this.value = value;
	}

	public void setHigher(int higher) {
		this.higher = higher;
	}

	public boolean isMatch(int org){
		 return org>=this.lower&&org<=this.higher;
	 }

}
